import unittest
from Crypto.Cipher import AES
from Crypto.Util.Padding import pad, unpad


class AESCBCTestCase(unittest.TestCase):
    def setUp(self):
        self.data = b'0123456789ABCDEF0123456789ABCDEF'
        self.key = b'0123456789ABCDEF'
        self.iv = b'0123456789ABCDEF'

    def _encrypt(self, data):
        cipher = AES.new(self.key, AES.MODE_CBC, self.iv)
        return cipher.encrypt(pad(data, AES.block_size))

    def _decrypt(self, ciphertext):
        cipher = AES.new(self.key, AES.MODE_CBC, self.iv)
        return unpad(cipher.decrypt(ciphertext), AES.block_size)

    def test_decrypt_data_properly(self):
        encrypted = self._encrypt(self.data)
        decrypted = self._decrypt(encrypted)
        self.assertEqual(decrypted, self.data, "Decrypted data should match original input")


if __name__ == '__main__':
    unittest.main()
